/* Flash algorithm for MM32SPIN0230 3KB Flash
 *
 * DAPLink Interface Firmware
 * Copyright (c) 2009-2024 Arm Limited, All Rights Reserved
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated from 'MM32SPIN0230_3.FLM' (MM32SPIN0230 3KB Flash)
// digest = 97091189fc892a911de1c93679d475c01650df16868deb48582aaeadbb7e84b4, file size = 14484
// algo version = 0x101, algo size = 556 (0x22c)
#include "flash_blob.h"

static const uint32_t MM32SPIN0230_3_flash_prog_blob[] = {
    0xe7fdbe00,
    0x497f4880, 0x49806041, 0x47706041, 0x4a7c487d, 0x497d6042, 0x60826041, 0x21006081, 0x68c16001,
    0x43112214, 0x69c060c1, 0xd4060740, 0x49774878, 0x21066001, 0x49776041, 0x20006081, 0x48714770,
    0x22806901, 0x61014311, 0x15826901, 0x61014391, 0x47702000, 0x2101b530, 0x06c9486a, 0x68c16141,
    0x43212414, 0x690160c1, 0x43292504, 0x69016101, 0x43112240, 0x49686101, 0xe0004a65, 0x68c36011,
    0xd1fb07db, 0x43a96901, 0x68c16101, 0xd0044221, 0x432168c1, 0x200160c1, 0x2000bd30, 0xb530bd30,
    0x68ca4958, 0x431a2314, 0x4a5560ca, 0x4a56608a, 0x6148608a, 0x24206908, 0x61084320, 0x22406908,
    0x61084310, 0x4a524854, 0x6010e000, 0x07ed68cd, 0x6908d1fb, 0x610843a0, 0x401868c8, 0x68c8d003,
    0x60c84318, 0xbd302001, 0xf7ffb530, 0x4d4bff89, 0xf7ff4628, 0x4943ffd4, 0x158a6908, 0x61084310,
    0x24106908, 0x61084320, 0x80284845, 0x4a404842, 0x6010e000, 0x07db68cb, 0x6908d1fb, 0x610843a0,
    0x221468c8, 0xd0034010, 0x431068c8, 0x200160c8, 0xb500bd30, 0xffd8f7ff, 0xff8cf7ff, 0x054020ff,
    0xffadf7ff, 0xbd002000, 0x4a2eb570, 0x231468d1, 0x60d14319, 0x054921ff, 0x25022420, 0xd0014288,
    0xd9024288, 0x43216911, 0x6911e001, 0x61114329, 0x69106150, 0x43082140, 0x48276110, 0xe0004924,
    0x68d66008, 0xd1fb07f6, 0x43a86910, 0x69106110, 0x611043a0, 0x401868d0, 0x68d0d003, 0x60d04318,
    0xbd702001, 0x47702001, 0x4d16b5f0, 0x08491c49, 0x004968eb, 0x43232404, 0x261060eb, 0xe01a4b16,
    0x4334692c, 0x8814612c, 0x4c118004, 0x6023e000, 0x07ff68ef, 0x692cd1fb, 0x612c43b4, 0x271468ec,
    0xd005423c, 0x211468e8, 0x60e84308, 0xbdf02001, 0x1e891c80, 0x29001c92, 0x2000d1e2, 0x0000bdf0,
    0x45670123, 0x40022000, 0xcdef89ab, 0x00005555, 0x40003000, 0x00000fff, 0x0000aaaa, 0x1ffff800,
    0x00005aa5, 0x00000000};

// Start address of flash
#define MM32SPIN0230_3_flash_start 0x1fe00000
// Size of flash
#define MM32SPIN0230_3_flash_size 0x00000c00
// Size of sector
#define MM32SPIN0230_3_sector_size 0x00000400

static const program_target_t MM32SPIN0230_3_flash = {
    0x20000011, // Init
    0x20000043, // UnInit
    0x20000137, // EraseChip
    0x2000014d, // EraseSector
    0x200001ad, // ProgramPage
    0x00000000, // Verify

    // BKPT : start of blob + 1
    // RSB  : blob start + header + rw data offset
    // RSP  : stack pointer
    {
        0x20000001,
        0x20000228,
        0x20000c00,
    },

    // mem buffer location
    0x20000c00,
    // location to write prog_blob in target RAM
    0x20000000,
    // prog_blob size
    sizeof(MM32SPIN0230_3_flash_prog_blob),
    // address of prog_blob
    MM32SPIN0230_3_flash_prog_blob,
    // ram_to_flash_bytes_to_be_written
    0x00000400,
};
